package org.flower.web.servlet;

import com.jspsmart.upload.*;
import org.flower.bean.Carousel;
import org.flower.dao.CarouselDao;
import org.flower.dao.impl.CarouselDaoImpl;
import org.flower.service.CarouselService;
import org.flower.service.impl.CarouselServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 旋转木马servlet
 *
 * @author Aizen
 * @date 2021/12/27
 */
@WebServlet(urlPatterns="/manager/CarouselAjaxServlet.shtml")
public class CarouselAjaxServlet extends HttpServlet {


	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}


	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取Ajax请求发过来的轮播图id
		String idsstr = request.getParameter("idsstr");
		//如果不为空 则代表是Ajax发送的请求
		if(idsstr!=null){
			String[] ids = idsstr.split(",");
			CarouselDao cd = new CarouselDaoImpl();
			for (int i = 0; i < ids.length; i++) {
				cd.CarouselSort(Integer.parseInt(ids[i]),(i+1));
			}
		}
	}

}
